package com.hehao.java_basic.design_mode.behaviour.strategy.practice;

import com.hehao.common.entiy.Receipt;

/**
 * @author Damon
 * @date 2023/6/28
 * 上下文类，持有上下文类
 */
public class ReceiptStrategyContext {
    private IReceiptHandleStrategy receiptHandleStrategy;

    /**
     * 设置策略接口
     * @param receiptHandleStrategy 具体的策略
     */
    public void setReceiptHandleStrategy(IReceiptHandleStrategy receiptHandleStrategy) {
        this.receiptHandleStrategy = receiptHandleStrategy;
    }

    public void handleReceipt(Receipt receipt){
        if (null != receiptHandleStrategy) {
            receiptHandleStrategy.handleReceipt(receipt);
        }
    }


}
